home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / ace / c / menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-04  |  2.6 KB  |  132 lines

  1. /* << ACE >>
  2.  
  3.    -- Amiga BASIC Compiler --
  4.  
  5.    ** Parser: menu functions **
  6.    ** Copyright (C) 1998 David Benn
  7.    ** 
  8.    ** This program is free software; you can redistribute it and/or
  9.    ** modify it under the terms of the GNU General Public License
  10.    ** as published by the Free Software Foundation; either version 2
  11.    ** of the License, or (at your option) any later version.
  12.    **
  13.    ** This program is distributed in the hope that it will be useful,
  14.    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    ** GNU General Public License for more details.
  17.    **
  18.    ** You should have received a copy of the GNU General Public License
  19.    ** along with this program; if not, write to the Free Software
  20.    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    Author: David J Benn
  23.      Date: 9th,10th November 1993,
  24.        13th January 1994
  25. */
  26.  
  27. #include "acedef.h"
  28.  
  29. /* externals */
  30. extern    int    sym;
  31. extern    int    lastsym;
  32.  
  33. /* functions */
  34. void clear_menu()
  35. {
  36. /* MENU CLEAR */
  37.  
  38.     insymbol();
  39.     
  40.     gen("jsr","_ClearMenu","  ");
  41.     enter_XREF("_ClearMenu");
  42.      enter_XREF("_IntuitionBase");
  43. }
  44.  
  45. void wait_menu()
  46. {
  47. /* MENU WAIT */
  48.     
  49.     insymbol();
  50.  
  51.     gen("jsr","_WaitMenu","  ");
  52.     enter_XREF("_WaitMenu");
  53. }
  54.  
  55. void menu()
  56. {
  57. /* MENU menu-id,item-id,state[,title-string[,command-key]]
  58.    MENU WAIT menu-id
  59.    MENU CLEAR
  60.    MENU ON | OFF | STOP
  61. */
  62. int  mtype;
  63.  
  64.     insymbol();
  65.     
  66.     if (sym == onsym || sym == offsym || sym == stopsym)
  67.         change_event_trapping_status(lastsym);
  68.     else
  69.     if (sym == clearsym)
  70.         clear_menu();
  71.     else
  72.         if (sym == waitsym)
  73.         wait_menu();
  74.     else
  75.     {
  76.          if (make_integer(expr()) == shorttype) 
  77.             make_long();  /* menu-id */
  78.     
  79.          if (sym != comma) _error(16);
  80.          else
  81.          {
  82.              insymbol();
  83.               if (make_integer(expr()) == shorttype) 
  84.                     make_long();  /* item-id */
  85.       
  86.             if (sym != comma) _error(16);
  87.             else
  88.             {
  89.                 insymbol();
  90.                   if (make_integer(expr()) == shorttype) 
  91.                         make_long();  /* state */
  92.  
  93.                 if (sym != comma)
  94.                 { 
  95.                     gen("jsr","_ChangeMenuState","  ");
  96.                     gen("add.l","#12","sp");
  97.  
  98.                     enter_XREF("_ChangeMenuState");    
  99.                     return;    
  100.                 }
  101.             }
  102.          }
  103.  
  104.         if (sym != comma) _error(16);
  105.         else
  106.         {
  107.             insymbol();
  108.             mtype = expr();    
  109.  
  110.             if (mtype != stringtype) _error(4); /* title-string */
  111.         }
  112.  
  113.         if (sym == comma)
  114.         {
  115.             insymbol();
  116.             mtype = expr();
  117.             
  118.             if (mtype != stringtype) _error(4);
  119.         }
  120.         else
  121.             gen("move.l","#0","-(sp)");    /* command-key */
  122.  
  123.      /* call function */
  124.      gen("jsr","_ModifyMenu","  ");
  125.      gen("add.l","#20","sp");
  126.  
  127.      enter_XREF("_ModifyMenu");
  128.       enter_XREF("_IntuitionBase");
  129.       enter_XREF("_GfxBase");
  130.     }
  131. }
  132.